package app_config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MysqlConfig
	RedisConfig
}
type MysqlConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	DbName   string
}
type RedisConfig struct {
	Host     string
	Port     int
	Password string
	DB       int
}

var AppConf AppConfig

func InitApp() {
	viper.SetConfigFile("./app_config./app.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	viper.Unmarshal(&AppConf)
	fmt.Println("viper 动态配置连接成功:", AppConf)
}
